package com.mes.task.dao;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Property;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.mes.common.dao.BasicDao;
import com.mes.task.dao.iface.IOperationTaskLinkDao;
import com.mes.task.domain.OperationTask;
import com.mes.task.domain.OperationTaskLink;

@Repository
public class OperationTaskLinkDao extends BasicDao<OperationTaskLink> implements IOperationTaskLinkDao {

	/**
	 * 通过工序任务唯一号获取工序的前置链接
	 * @param operationTaskUid
	 * @return
	 */
	public List<OperationTaskLink> getPredOperationTaskLinks(String operationTaskUid) {
		List list = null;
		try
		{
			Session session = this.getSessionFactory().getCurrentSession();
			Criteria crit = session.createCriteria(OperationTaskLink.class);
			crit.add(Restrictions.eq("succOperationTaskUid", operationTaskUid));
			list = crit.list();
		}
		catch (Exception e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return list;
	}
	
	/**
	 * 通过工序任务唯一号获取工序的后置链接
	 * @param operationTaskUid
	 * @return
	 */
	public List<OperationTaskLink> getSuccOperationTaskLinks(String operationTaskUid) {
		List list = null;
		try
		{
			Session session = this.getSessionFactory().getCurrentSession();
			Criteria crit = session.createCriteria(OperationTaskLink.class);
			crit.add(Restrictions.eq("predOperationTaskUid", operationTaskUid));
			list = crit.list();
		}
		catch (Exception e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return list;
	}
	
	
}
